package operation;

import book.book;
import book.booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2022-11-18
 * Time: 20:40
 */
public class returnoperation implements Ioper{
    @Override
    public void work(booklist book) {
        System.out.println("请归还你要借的书名");
        Scanner scanner = new Scanner(System.in);
        String name=scanner.nextLine();
        int cur=book.getBookSize();
        for (int i = 0; i < cur; i++) {
            book book1=  book.getBooks(i);
            if(book1.isPan()&& book1.getName().equals(name) ){
                System.out.println("归还成功");
                book1.setPan(false);
                System.out.println(book1);
                break;
            }else {
                System.out.println("该书已经归还，归还失败");
                break;
            }
        }
    }
}
